/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MensajesInfo.java
 *
 * Created on 11-ene-2013, 1:22:11
 */
package gui;

import controladores.ControladorPrincipal;
import javax.swing.ImageIcon;
import utilidades.JFrameConFondo;

/**
 *
 * @author NiCo
 */
public class MensajesConf extends JFrameConFondo {

    boolean confirmacion = false;
    boolean continuar = false;
    private final JFrameConFondo quien;
    private String propiedad;

    /** Creates new form MensajesInfo */
    public MensajesConf(String propiedad, JFrameConFondo quien) {
        initComponents();
        this.setAlwaysOnTop(true);
        setImagen("/imagenes/fondo.png");
        lblTitulo.setIcon(new ImageIcon(getClass().getResource("/imagenes/titulo-notificacion.png")));
        lblIcono.setIcon(new ImageIcon(getClass().getResource("/imagenes/icono-notificacion.png")));
        lblMensaje.setText("<html>" + ControladorPrincipal.getInstance().getPropiedades().getProperty(propiedad));
        this.quien = quien;
        this.propiedad = propiedad;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnCerrar = new javax.swing.JButton();
        lblTitulo = new javax.swing.JLabel();
        btnSi = new javax.swing.JButton();
        lblMensaje = new javax.swing.JLabel();
        lblIcono = new javax.swing.JLabel();
        btnNo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        btnCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cerrar-normal.png"))); // NOI18N
        btnCerrar.setBorder(null);
        btnCerrar.setBorderPainted(false);
        btnCerrar.setFocusPainted(false);
        btnCerrar.setName("btnCerrar"); // NOI18N
        btnCerrar.setOpaque(false);
        btnCerrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnCerrarMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnCerrarMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                btnCerrarMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCerrarMouseReleased(evt);
            }
        });
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });

        lblTitulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblTitulo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/titulo-confirmacion.png"))); // NOI18N
        lblTitulo.setName("lblTitulo"); // NOI18N

        btnSi.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/si.png"))); // NOI18N
        btnSi.setBorderPainted(false);
        btnSi.setFocusPainted(false);
        btnSi.setName("btnSi"); // NOI18N
        btnSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSiActionPerformed(evt);
            }
        });

        lblMensaje.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblMensaje.setText("jLabel2");
        lblMensaje.setName("lblMensaje"); // NOI18N

        lblIcono.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icono-pregunta.png"))); // NOI18N
        lblIcono.setName("lblIcono"); // NOI18N

        btnNo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/no.png"))); // NOI18N
        btnNo.setBorderPainted(false);
        btnNo.setFocusPainted(false);
        btnNo.setName("btnNo"); // NOI18N
        btnNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(lblTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnCerrar))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(lblIcono, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lblMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btnSi, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnNo, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(125, 125, 125))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(lblTitulo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCerrar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblMensaje, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(lblIcono, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnSi, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnNo, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCerrarMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseEntered

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-activo.png")));     }//GEN-LAST:event_btnCerrarMouseEntered

    private void btnCerrarMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseExited

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-normal.png")));     }//GEN-LAST:event_btnCerrarMouseExited

    private void btnCerrarMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMousePressed

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-click.png")));     }//GEN-LAST:event_btnCerrarMousePressed

    private void btnCerrarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseReleased

        btnCerrar.setIcon(new ImageIcon(getClass().getResource("/imagenes/cerrar-normal.png")));     }//GEN-LAST:event_btnCerrarMouseReleased

    private void btnSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSiActionPerformed
        confirmacion = true;
        continuar = true;
        try {
            ChequearDatos aux = (ChequearDatos) quien;
            if (propiedad.equals("NinoExisteCaso")) {
                aux.continuarNuevo();
            } else {
                if (propiedad.equals("NinoExisteAct")) {
                    aux.continuarActualizacion();
                }
            }
        } catch (Exception e) {
        }
        try {
            ModificarActualizacion aux = (ModificarActualizacion) quien;
            aux.guardarDatos('s');
        } catch (Exception e) {
        }
        try {
            ModificarCaso aux = (ModificarCaso) quien;
            aux.guardarDatos('s');
        } catch (Exception e) {
        }
        try {
            EliminarSeguimiento aux = (EliminarSeguimiento) quien;
            aux.confirmado();
        } catch (Exception e) {
        }
        try {
            EliminarIntervencion aux = (EliminarIntervencion) quien;
            aux.confirmado();
        } catch (Exception e) {
        }
        try {
            EliminarLlamado aux = (EliminarLlamado) quien;
            aux.confirmado();
        } catch (Exception e) {
        }
        this.dispose();
    }//GEN-LAST:event_btnSiActionPerformed

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCerrarActionPerformed

    private void btnNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoActionPerformed
        confirmacion = false;
        continuar = true;
        try {
            ChequearDatos aux = (ChequearDatos) quien;
            if (propiedad.equals("NinoExisteCaso")) {
                aux.continuarNuevo();
            } else {
                if (propiedad.equals("NinoExisteAct")) {
                    aux.continuarActualizacion();
                }
            }
        } catch (Exception e) {
        }
        try {
            ModificarActualizacion aux = (ModificarActualizacion) quien;
            aux.guardarDatos('n');
        } catch (Exception e) {
        }
        try {
            ModificarCaso aux = (ModificarCaso) quien;
            aux.guardarDatos('n');
        } catch (Exception e) {
        }
        this.dispose();
    }//GEN-LAST:event_btnNoActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCerrar;
    private javax.swing.JButton btnNo;
    private javax.swing.JButton btnSi;
    private javax.swing.JLabel lblIcono;
    private javax.swing.JLabel lblMensaje;
    private javax.swing.JLabel lblTitulo;
    // End of variables declaration//GEN-END:variables

    public boolean isConfirmacion() {
        return confirmacion;
    }

    public boolean isContinuar() {
        return confirmacion;
    }
}
